from Devices.Chiot.BsDevs.ComDev.ComDevParser import ComDevParser

class FallSensorParser(ComDevParser):
    def ParseHeartbeat(msgValue, fullStatus):
        # 解析特有数据
        ret, strValue = FallSensorParser.GetStrProperty(msgValue, "radarModel")
        if ret:
            fullStatus.radarModel = strValue

        ret, strValue = FallSensorParser.GetStrProperty(msgValue, "radarVer")
        if ret:
            fullStatus.radarVer = strValue

        if not "stateValue" in msgValue:
            return True
        stateValue = msgValue["stateValue"]

        ret, value = FallSensorParser.GetIntProperty(stateValue, "existStatus", "status")
        if ret:
            fullStatus.existStatus = value

        ret, value = FallSensorParser.GetIntProperty(stateValue, "motionStatus", "status")
        if ret:
            fullStatus.motionStatus = value

        ret, value = FallSensorParser.GetIntProperty(stateValue, "fallStatus", "status")
        if ret:
            fullStatus.fallStatus = value
            
        ret, value = FallSensorParser.GetIntProperty(stateValue, "fallStatus", "fallTime")
        if ret:
            fullStatus.fallTime = value

        ret, value = FallSensorParser.GetIntProperty(stateValue, "staticStatus", "status")
        if ret:
            fullStatus.staticStatus = value

        ret, value = FallSensorParser.GetIntProperty(stateValue, "staticStatus", "staticTime")
        if ret:
            fullStatus.staticStatus = value

        ret, value = FallSensorParser.GetIntProperty(stateValue, "fixHeight", "height")
        if ret:
            fullStatus.fixHeight = value
        
        return True
